public class Solve {
    public String solve (String IP) {
        // write code here
        if (IP.charAt(0) == '.' || IP.charAt(0) == ':'
                || IP.charAt(IP.length()-1) == '.' || IP.charAt(IP.length()-1) == ':') {
            return "Neither";
        }
        String[] ss1 = IP.split("\\.");
        String[] ss2 = IP.split(":");
        if (ss1.length == 4) {
            for (String s : ss1) {
                if (!ipv4Valid(s)) {
                    return "Neither";
                }
            }
            return "IPv4";
        } else if (ss2.length == 8) {
            for (String s : ss2) {
                if (!ipv6Valid(s)) {
                    return "Neither";
                }
            }
            return "IPv6";
        } else {
            return "Neither";
        }
    }

    private boolean ipv6Valid(String s) {
        if (s.length() == 0 || s.length() > 4) {
            return false;
        }
        String ss = s.toUpperCase();
        boolean flg = false;
        for (char c : ss.toCharArray()) {
            if (c != '0') {
                flg = true;
            }
            if (!Character.isDigit(c) && c > 'F') {
                return false;
            }
        }
        if (s.length() > 1 && !flg) {
            return false;
        }
        return true;
    }

    private boolean ipv4Valid(String s) {
        if (s.length() == 0) {
            return false;
        }
        if (s.charAt(0) == '0' && s.length() > 1) {
            return false;
        }
        int num;
        try {
            num = Integer.valueOf(s);
        } catch (Exception e) {
            return false;
        }
        return num >= 0 && num <= 255;
    }

    public static void main(String[] args) {
        System.out.println(new Solve().solve("2001:0db8:85a3:0:0:8A2E:0370:7334:"));
    }
}
